package c4.application.transactions.Drivers;

import java.util.Properties;

import c4.application.transactions.AccountRepresentation;
import c4.application.transactions.Task;
import c4.application.transactions.TransactionManager;
import c4.application.transactions.Worker;
import c4.common.Constants;

public class DriverCustomerLogin {

	Properties display;

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		DriverCustomerLogin driver = new DriverCustomerLogin();
	}

	public DriverCustomerLogin() {
		TransactionManager manager;
		Worker worker;
		Task task;
		AccountRepresentation representation;

		manager = new TransactionManager();
		worker = manager.getWorker();
		loadDisplay();

		task = new Task(Constants.CUSTOMER_LOGIN);
		task.addParameter(Constants.PIN, "1234");
		task.addParameter(Constants.ACCOUNT_NUMBER, "1");

		representation = worker.request(task);

		if (representation.getSuccessful()) { // everything was Ok, so
												// display
			display.putAll(representation.getUpdates()); // load all
															// updated
															// values
			display.list(System.out); // display with updates
		}

		else
			// there was an error with the request, so errors should be
			// displayed
			System.out.println(representation.getErrorMessages()); // display
																	// error
	}

	/**
	 * Initialize all of the values that will be displayed by Swing objects
	 */
	private void loadDisplay() {
		display = new Properties();

		display.setProperty(Constants.PIN, "");
		display.setProperty(Constants.NAME, "");
		display.setProperty(Constants.DOB, "");
		display.setProperty(Constants.SSN, "");
		display.setProperty(Constants.STREET, "");
		display.setProperty(Constants.ZIP, "");
		display.setProperty(Constants.CITY, "");
		display.setProperty(Constants.STATE, "");
		display.setProperty(Constants.VOICEMAIL, "");
		display.setProperty(Constants.CALLER_ID, "");
		display.setProperty(Constants.THREE_WAY, "");
		display.setProperty(Constants.DISTANCE_PROVIDER, "");
		display.setProperty(Constants.ACCOUNT_NUMBER, "");
		display.setProperty(Constants.PHONE0, "");
		display.setProperty(Constants.PHONE1, "");
		display.setProperty(Constants.PHONE2, "");
		display.setProperty(Constants.PHONE3, "");

		display.setProperty(Constants.TROUBLE0, "");
		display.setProperty(Constants.TROUBLE1, "");
		display.setProperty(Constants.TROUBLE2, "");
		display.setProperty(Constants.TROUBLE3, "");

		display.setProperty(Constants.SERVICE0, "");
		display.setProperty(Constants.SERVICE1, "");
		display.setProperty(Constants.SERVICE2, "");
		display.setProperty(Constants.SERVICE3, "");

	}

}
